package com.example.dllo.my36kr.main;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by dllo on 16/8/15.
 */
public class MainAdapter extends FragmentPagerAdapter {
    ArrayList<String> arrayList = new ArrayList<>();
    ArrayList<Fragment>fragments;

    public void setFragments(ArrayList<Fragment> fragments) {
        this.fragments = fragments;

        arrayList.add("新闻");
        arrayList.add("股份投资");
        arrayList.add("发现");
        arrayList.add("消息");
        arrayList.add("我的");


    }

    public MainAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments != null ? fragments.size() : 0 ;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return arrayList.get(position);
    }
}
